package edu.sjsu.itack.bl;

import edu.sjsu.itack.dao.UserDao;
import edu.sjsu.itack.entity.User;
import edu.sjsu.itack.util.ITackException;

public class UserBl {

	private UserDao userDao;
	
	public UserBl() {
       this.userDao = new UserDao();
	}
	
	public User validateUser(String email, String password) throws ITackException{
		User user = userDao.findUserByEmail(email);
		
		if (!user.getPassword().equals(password))
			throw new ITackException("EXC100", null);
		
		user.setPassword(null);
		return user;
	}
	
	public void signUpUser(User user) throws ITackException{
		userDao.createUser(user);
	}
}
